package com.szholly.data.general;

/**
 * 类功能说明 定义分页信息
 */
public class PageInfo {
	/**
	 * 获取或设置页面值大小
	 */
	private int pageSize = 25;

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int value) {
		if (value <= 0)
			pageSize = 25;
		else
			pageSize = value;
	}

	/**
	 * 获取或设置当前页面索引
	 */
	private int pageIndex = 1;

	public int getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(int value) {
		if (value <= 0)
			pageIndex = 1;
		else if (value > pageCount)
			pageIndex = pageCount;
		else
			pageIndex = value;
	}

	/**
	 * 获取页面总数
	 */
	private int pageCount = 99999999;
	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int value) {
		pageCount = value;
	}

	/**
	 * 获取总记录数
	 */
	private int rowCount = -1;
	public int getRowCount() {
		return rowCount;
	}

	public void setRowCount(int value) {
		rowCount = value;
		if(rowCount<0){
			rowCount = 0;
		}
		int pCount = rowCount / pageSize;
		if((pageSize*pCount) < rowCount){
			pCount++;
		}
		pageCount = pCount;
	}

	/**
	 * 重新计算总记录数
	 */
	private boolean refresRowCount = false;

	public boolean getRefreshRowCount() {
		return refresRowCount;
	}

	public void setRefreshRowCount(boolean value) {
		refresRowCount = value;
	}

	/**
	 * 获取唯一值: 与QueryFilter一起组成DataCache的key
	 */
	public String getKey() {
		String hashCode = "";
		hashCode += pageCount + "_";
		hashCode += pageIndex + "_";
		hashCode += pageSize + "_";
		hashCode += rowCount;
		return hashCode;
	}
}